how to create a background function